package com.atguigu.gulimall.product.config;

import com.aliyun.oss.OSS;
import com.aliyun.oss.OSSClientBuilder;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

@Configuration
@EnableConfigurationProperties(value = {AliOssProperties.class})
public class AliOssAutoConfiguration {

    @Bean
    public OSSClientBuilder ossClientBuilder(){
        return new OSSClientBuilder();
    }

    @Bean
    public OSS oss(OSSClientBuilder builder, AliOssProperties properties){
        return builder.build(properties.getEndpoint(), properties.getAccessKeyId(), properties.getAccessKeySecret());
    }

}
